package com.cloud.interceptor.feign;

import feign.Request;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import io.seata.core.context.RootContext;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

/**
 * @Author wenbo
 * @Date 2022/12/14 13:34
 **/
public class CustomFeignInterceptor implements RequestInterceptor {
    private Logger logger = LoggerFactory.getLogger(this.getClass());
    @Override
    public void apply(RequestTemplate template) {
        //记录日志
        logger.info("feign拦截器");
        //修改请求头
        template.header("headName","请求头");
        String xid = RootContext.getXID();
        //template.header(RootContext.KEY_XID, xid);
        //template.query("id","23");
        //template.uri("/item/9");
    }
}
